package org.boulderfoodrescue.webapp.client.events;

import org.boulderfoodrescue.webapp.shared.Pickup;

import com.google.gwt.event.shared.GwtEvent;

public class PickupUpdatedEvent extends GwtEvent<PickupUpdatedHandler>{
	private static final Type<PickupUpdatedHandler> TYPE = new Type<PickupUpdatedHandler>();
	private ChangeType changeType;
	private Pickup pickup;

	public PickupUpdatedEvent(ChangeType changeType, Pickup pickup) {

		this.changeType = changeType;
		this.pickup = pickup;
	}

	public static Type<PickupUpdatedHandler> getType() {
		return TYPE;
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<PickupUpdatedHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(PickupUpdatedHandler handler) {
		switch(changeType)
		{
		case Added: handler.onPickupAdded(this);break;
		case Removed: handler.onPickupRemoved(this);break;
		case Updated: handler.onPickupUpdated(this);break;
		}
	}

	public Pickup getValue(){
		return pickup;
	}
}